package cc.catface.api.biz;

import cc.catface.common.aspect.NetLog;
import cc.catface.common.output.Result;
import cc.catface.dao.biz.app.dto.*;
import cc.catface.service.ApArticleServiceImpl;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@ApiSupport(order = 10)
@Api(tags = "[ap]文章")
@RestController
@RequestMapping("ap/article")
public class ApArticleController {
    @Autowired
    private ApArticleServiceImpl apArticleService;

    @ApiOperationSupport(order = 10)
    @NetLog("新增文章")
    @ApiOperation(value = "新增文章=开发")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = AddArticleOUTDTO.class))
    @PostMapping("addArticle")
    public Result<AddArticleOUTDTO> addArticle(@RequestBody AddArticleINDTO in) {
        return apArticleService.addArticle(in);
    }

    @ApiOperationSupport(order = 20)
    @NetLog("根据频道ID查文章列表")
    @ApiOperation(value = "根据频道ID查文章列表=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = ListByChannelIdOUTDTO.class))
    @PostMapping("listByChannelId")
    public Result<ListByChannelIdOUTDTO> listByChannelId(@RequestBody ListByChannelIdINDTO in) {
        return apArticleService.listByChannelId(in);
    }

    @ApiOperationSupport(order = 30)
    @NetLog("根据文章ID查详细文章内容")
    @ApiOperation(value = "根据文章ID查详细文章内容=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = GetContentOUTDTO.class))
    @PostMapping("getContent")
    public Result<GetContentOUTDTO> getContent(@RequestBody GetContentINDTO in) {
        return apArticleService.getContent(in);
    }

    @ApiOperationSupport(order = 31)
    @NetLog("根据文章ID查评论及回复")
    @ApiOperation(value = "根据文章ID查评论及回复=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = ArticleCommentOUTDTO.class))
    @PostMapping("articleComment")
    public Result<List<ArticleCommentOUTDTO>> articleComment(@RequestBody ArticleCommentINDTO in) {
        return apArticleService.articleComment(in);
    }
}
